﻿using System;
using App.Entity;
using App.IServices;
using App.IRepository;
using System.Collections.Generic;
using App.Code;

/*!
* 文件描述：一切从简，只为了更懒！
*/
namespace App.Services
{
	public partial class Sys_FilterIPServices : BaseServices<Sys_FilterIP> , ISys_FilterIPServices
	{
		ISys_FilterIPRepository _ISys_FilterIPRepository;
		public Sys_FilterIPServices(ISys_FilterIPRepository __ISys_FilterIPRepository)
		{
			this._ISys_FilterIPRepository = __ISys_FilterIPRepository;
			base._IBaseRepository = __ISys_FilterIPRepository;
		}

        public void DeleteForm(string keyValue)
        {
            _ISys_FilterIPRepository.Delete(c => c.Id == keyValue);
        }

        public Sys_FilterIP GetForm(string keyValue)
        {
            return _ISys_FilterIPRepository.QuerySingle(c => c.Id == keyValue);
        }

        public List<Sys_FilterIP> GetList(string keyword)
        {
            var expression = ExtLinq.True<Sys_FilterIP>();
            if (!string.IsNullOrEmpty(keyword))
            {
                expression = expression.And(t => t.StartIP.Contains(keyword));
            }
            return _ISys_FilterIPRepository.QueryByWhere(expression, "DeleteTime");

        }

        public void SubmitForm(Sys_FilterIP filterIPEntity, string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                filterIPEntity.Modify(keyValue);
                _ISys_FilterIPRepository.Update(filterIPEntity);
            }
            else
            {
                filterIPEntity.Create();
                _ISys_FilterIPRepository.Insert(filterIPEntity);
            }
        }
    }
}